#ifndef _LEVEL_H
#define _LEVEL_H

#include "SFML\Graphics.hpp"
#include <vector>
#include <string>

class AnimatedTile;
class Tile;
class Entity;
class RenderManager;
class Level
{
public:
	Level(const std::string& filepath, int tileSize = 16);
	~Level(void);

	void update();
	void draw(RenderManager* renderManager);
	Tile* getTile(unsigned int x, unsigned int y);
	void loadLevel();
	void unloadLevel();
	int getWidth();
	int getHeight();
	unsigned short getTileSize() { return _tileSize; }
	void checkCollision(Entity* entity);
	void isOnGround(Entity* entity);
	void applyGravity(Entity* entity);
	void clearFlags(Entity* entity);
	const std::string& getID() { return _id; }

private:
	
	void loadTileset(const std::string& path);
	void setDimension();
	
	float _gravity;
	std::string _filepath;
	std::string _id;
	std::vector<std::vector<Tile*>> _map;
	std::vector<AnimatedTile*> _animatedTiles;
	std::vector<sf::Texture> _tiles;
	unsigned short _tileSize;
	unsigned int _w, _h;
};

#endif // _LEVEL_H